package com.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.model.User;

public interface UserDao {
	@Insert("insert into user (`name`) values (#{name})")
	public int add(User user);

	@Select("SELECT * FROM user WHERE id = #{userId}")
	public User getUser(@Param("userId") String userId);

	@Select("select *from User")
	public List<User> retrieveAllUsers();

	// 注意这里只有一个参数，则#{}中的标识符可以任意取
	@Select("select *from User where id=#{idss}")
	public User retrieveUserById(int id);

	@Select("select *from User where id=#{id} and name like #{name}")
	public User retrieveUserByIdAndName(@Param("id") int id, @Param("name") String names);

	@Insert("INSERT INTO user(name,age,id) VALUES(#{name}, #{age},#{id})")
	public void addNewUser(User user);

	@Delete("delete from user where id=#{id}")
	public void deleteUser(int id);

	@Update("update user set name=#{name},age=#{age} where id=#{id}")
	public void updateUser(User user);

}
